VT-d: use correct BDF for VF to search VT-d unit
authorChao Gao <chao.gao@intel.com>
Fri, 1 Sep 2017 09:02:23 +0000 (11:02 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 1 Sep 2017 09:02:23 +0000 (11:02 +0200)
commitc286af54c7177c14180121b422d8df7281e547cb
tree49005ceffd46e5f4891b0b4f3bc8045984895303
parente1c10ecdf7f0a4437e631bdbf887ce4af4c03a1b
VT-d: use correct BDF for VF to search VT-d unit

When SR-IOV is enabled, 'Virtual Functions' of a 'Physical Function'
are under the scope of the same VT-d unit as the 'Physical Function'.
A 'Physical Function' can be a 'Traditional Function' or an ARI
'Extended Function'. And furthermore, 'Extended Functions' on an
endpoint are under the scope of the same VT-d unit as the 'Traditional
Functions' on the endpoint. To search VT-d unit for a VF, if its PF
isn't an extended function, the BDF of PF should be used. Otherwise
the BDF of a traditional function in the same device with the PF
should be used.

Current code uses PCI_SLOT() to recognize an ARI 'Extended Funcion'.
But it is conceptually wrong w/o checking whether PF is an extended
function and would lead to match VFs of a RC integrated PF to a wrong
VT-d unit.

This patch overrides VF 'is_extfn' field and uses this field to
indicate whether the PF of this VF is an extended function. The field
helps to use correct BDF to search VT-d unit.

Reported-by: Crawford, Eric R <Eric.R.Crawford@intel.com>
Signed-off-by: Chao Gao <chao.gao@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Crawford, Eric R <Eric.R.Crawford@intel.com>
xen/drivers/passthrough/pci.c
xen/drivers/passthrough/vtd/dmar.c
xen/include/xen/pci.h